package com.bot.nft.module.dc.controller;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bot.common.pojo.CommonResult;
import com.bot.nft.module.dc.domain.bo.DcFlowQueryBo;
import com.bot.nft.module.dc.domain.vo.DcFlowLogVo;
import com.bot.nft.module.dc.service.IDcFlowLogService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author RenXiaoZheng
 * @since 2024-01-24
 */
@RestController
@RequestMapping("/flow")
public class DcFlowLogController {

    @Resource
    IDcFlowLogService dcFlowService;

    //分页查询流转记录
    @RequestMapping("/{pageNo}/{pageSize}/queryDcFlow.do")
    public CommonResult<Page> selectDcFlow(@RequestBody DcFlowQueryBo dcFlowQueryBo,
                                           @PathVariable("pageNo") Integer pageNo,
                                           @PathVariable("pageSize") Integer pageSize) {
        //调用接口
        Page<DcFlowLogVo> dcFlowLogVoPage = dcFlowService.queryDcFlowLog(dcFlowQueryBo.getInPhone(), dcFlowQueryBo.getOutPhone(), dcFlowQueryBo.getName(), pageNo, pageSize);
        CommonResult<Page> commonResult = new CommonResult<>();
        if (ObjectUtil.isNotNull(dcFlowLogVoPage)) {
            commonResult.setMsg("操作成功");
            commonResult.setCode(200);
            commonResult.setData(dcFlowLogVoPage);
        } else {
            commonResult.setMsg("操作失败");
            commonResult.setCode(500);
        }
        return commonResult;
    }

    //查看流转记录
    @RequestMapping("/getDcFlow.do")
    public CommonResult<List<DcFlowLogVo>> getDcFlow(@RequestParam("id") String id) {
        //调用接口
        List<DcFlowLogVo> dcFlowLog = dcFlowService.getDcFlowLog(id);
        CommonResult<List<DcFlowLogVo>> commonResult = new CommonResult<>();
        if (ObjectUtil.isNotNull(dcFlowLog)) {
            commonResult.setMsg("操作成功");
            commonResult.setCode(200);
            commonResult.setData(dcFlowLog);
        } else {
            commonResult.setMsg("操作失败");
            commonResult.setCode(500);
        }
        return commonResult;
    }

    //查看流转记录
//    @RequestMapping("/{certId}/getCertFlowLog.do")
//    public CommonResult<List<CertFlowVo>> getFlowLogByCertId(@PathVariable String certId) {
//        //调用接口
//        List<CertFlowVo> dcFlowLog = dcFlowService.getFlowLogByCertId(certId);
//        return CommonResult.data(dcFlowLog);
//    }

}
